package com;

import org.apache.commons.lang3.StringUtils;

import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class RelationTest {


    public static List<String> getUserIds() throws Exception {
        File file = new File("D:/abcd.txt");
        BufferedReader br = new BufferedReader(new FileReader(file));
        List<String> list = new ArrayList<String>();
        String lines = "";
        while ((lines = br.readLine()) != null) {
            list.add(lines);
        }

        br.close();
        return list;
    }
    public static List<String> gg() throws  Exception {
        File file = new File("D:/cccc.txt");
        BufferedReader br = new BufferedReader(new FileReader(file));
        List<String> list = new ArrayList<String>();
        String lines = "";
        while ((lines = br.readLine()) != null) {

            String[] strs = lines.split("\\?")[1].split("\\&");
            for (int i = 0; i < strs.length; i++) {

                if (strs[i].contains("userId")) {
                    list.add(strs[i].split("\\=")[1]);
                }
            }

        }
       return list;
    }

    private static List<String> tt(){

        String tr = "503612,507494,503473,507515,507555,507609,503681,507690,507718,507751,507988,503480,510750,505953,512259,616656,623864,627825,628653,634483,678445,691671,691943,696694,715603,744178,755376,757564,758502,758967,759302,759320";

        String trs[] = tr.split(",");

       return Arrays.asList(trs);
    }

    public static void main(String[] args) throws Exception {

      List<String> rr= tt();
     List<String> ss= gg();

       ss.retainAll(rr);

        System.out.println(ss);
       for(int i=0;i<ss.size();i++){
           System.out.println(ss.get(i));
       }
    }
}
